from django.utils.deprecation import MiddlewareMixin
from rest_framework.response import Response


# 一个中间件，即一个类
# class LaufMiddleware(MiddlewareMixin):
#
#     # 路由之前，处理请求
#     def process_request(self,request):
#
#         # 打印出客户端的IP地址
#         meta = request.META
#         client_ip = meta.get("REMOTE_ADDR")
#         print("客户端的IP:",client_ip)
#
#         return Response({"code":204, 'msg':'路由之前的中间件'})